Requirements of the Pub-Sub API

Learn the functional and non-functional requirements of a pub-sub service.

In the previous lesson, we discussed the structure of the pub-sub service. It’s an intermediate component in a microservice architecture that makes asynchronous communication possible between multiple services. Therefore, it needs an efficient API to direct the communication between the services. This lesson focuses on the requirements to design an API for the pub-sub service.

Requirements#

We identify the following essential functional and non-functional requirements for designing the pub-sub API.

Functional requirements#

The pub-sub service should allow the following features to a user:

  • Create topic/publish event: The pub-sub service should enable a user (publisher) to create a topic or publish an event related to any topic.

  • List topics: The service should allow users to request a list of available topics.

  • Subscribe: The service should allow users to subscribe to a specific topic.

  • Unsubscribe: The service should allow users to unsubscribe from a specific topic after they've subscribed to it.

Functional and non-functional requirements of a pub-sub service
Functional and non-functional requirements of a pub-sub service

Non-functional requirements#

Our API should be able to adhere to the following non-functional requirements for smooth operations.

  • Availability: Ideally, our API should be highly available because all publishers and subscribers depend on the availability of the service to work properly. Moreover, because this service is used as a building block in many design problems, the consequences can be catastrophic if it fails.

  • Scalability: Our API should smoothly handle a large number of requests from publishers. It should be able to handle many topics, many publishers per topic, and many consumers per topic.

  • Security: The pub-sub API and publisher-subscriber communication must be secure.

  • Low latency: The API needs to be highly performant to handle concurrent operations.

Prerequisites#

To design a pub-sub service, the following concepts can help us understand the process better:

Client-server communication protocols: This chapter focuses on various client-server communication protocols.

Event-driven protocols: This lesson describes various event-driven protocols. We will use the appropriate protocol to design the pub-sub API.

How will we design a pub-sub API?#

The design of the pub-sub API is divided into the following three lessons:

  • Pub-Sub API Design Decisions: This lesson expands on some important technical decisions that govern the pub-sub API design.

  • API Model for the Pub-Sub Service: In this lesson, we discuss the request and response structure to achieve the functional requirements of our API. We also identify important data entities and target endpoints to meet different functional requirements.

  • Pub-Sub API Design Evaluation and Latency Budget: Here, we discuss how we meet the non-functional requirements and estimate the response time of the pub-sub API. Furthermore, we discuss the notification service as a consumer of the pub-sub.

We will use the pub-sub service as a building block (such as notification service, asynchronous communication, etc.) in design problems later in the course. After discussing design decisions, the API model, and non-functional requirements, we now know how the pub-sub works as a notification service.

We’ll discuss design considerations in the next lesson.

Introduction to the Pub-Sub Service

Pub-Sub API Design Decisions